Skip to content

feat: add token metadata constants and upgrade stability test#194

Merged
Calebux merged 1 commit into
zintarh:mainfrom
DammyAji:feat/token-metadata-test
Jun 30, 2026
Merged

feat: add token metadata constants and upgrade stability test#194
Calebux merged 1 commit into
zintarh:mainfrom
DammyAji:feat/token-metadata-test

Conversation

@DammyAji

Copy link
Copy Markdown

Summary

Implements Issue #58: Add test for name(), symbol(), decimals() return values stability across contract upgrades.

Changes Made

1. Added Token Metadata Constants (src/constants.rs)

  • TOKEN_NAME = "Stellar Wrap Registry" - BREAKING CHANGE if modified
  • TOKEN_SYMBOL = "WRAP" - BREAKING CHANGE if modified
  • TOKEN_DECIMALS = 0 - Soulbound tokens are non-divisible
  • CONTRACT_DESCRIPTION = "Soulbound token registry for Stellar Wrap"
  • VERSION = 1 - Contract version to bump on WASM upgrades
  • HASH_PREVIEW_BYTES = 8 - Existing constant preserved

Each token constant includes documentation warning that changing these values is a BREAKING CHANGE for indexers and downstream consumers that rely on stable token identifiers.

2. Updated Contract Functions (src/lib.rs)

  • name() now uses TOKEN_NAME constant
  • symbol() now uses TOKEN_SYMBOL constant
  • decimals() now returns TOKEN_DECIMALS constant
  • contract_info() uses TOKEN_NAME and CONTRACT_DESCRIPTION constants
  • Contract metadata macros use TOKEN_NAME and CONTRACT_DESCRIPTION

3. Added Schema Version Constant (src/storage_types.rs)

  • SCHEMA_VERSION_V3 = 3 for v2 → v3 migration support

4. Added Regression Test (src/test.rs)

  • test_token_metadata() - Updated to use constants
  • test_token_metadata_preserved_after_upgrade() - New regression test verifying metadata stability across contract instances (simulates upgrade scenario)
  • test_contract_info_returns_correct_fields() - Updated to use constants
  • test_version_returns_expected_value() - Updated to use VERSION constant

Acceptance Criteria

  • Verify test covers all three functions (name, symbol, decimals)
  • Add constants for expected values to make changes intentional
  • Document that changing these is a breaking change for indexers

Closes #58

- Add TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS, CONTRACT_DESCRIPTION constants
- Add VERSION and SCHEMA_VERSION_V3 constants
- Update name(), symbol(), decimals(), contract_info() to use constants
- Add test_token_metadata_preserved_after_upgrade regression test
- Update test_token_metadata and test_contract_info tests to use constants

Closes zintarh#58
@DammyAji

Copy link
Copy Markdown
Author

@zintarh please kindly review. Thank you

@Calebux
Calebux merged commit 0f75cd5 into zintarh:main Jun 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test for name(), symbol(), decimals() return values

3 participants